package com.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bean.wd_ht_customer;
import com.service.CustomerService;

@Controller
@RequestMapping("/wd_ht_customer")
public class CustomerAction {
	@Autowired
	private CustomerService service;
	
	@RequestMapping("/toList.do")
	public String toList(Model model,wd_ht_customer bean){
		System.out.println("111111111111111111");
		List<wd_ht_customer> list = service.getList(bean);
		System.out.println(list);
		model.addAttribute("list", list);
		return "Customer1";
	}
	@RequestMapping("/toAdd.do")
	public String toAdd(wd_ht_customer bean){
		int i = service.toAdd(bean);
		System.out.println(i);
		return "redirect:toList.do";
	}
	@RequestMapping("/Add.do")
	public String Add(wd_ht_customer bean){
		return "addCustomer";
	}
	@RequestMapping("/toUpdate.do")
	public String toUpdate(String customerId,Model model){
		wd_ht_customer bean = service.selectByPrimaryKey(customerId);
		System.out.println("2222222222222");
		model.addAttribute("wd_ht_customer", bean);
		return "updateCustomer";
	}
	
	@RequestMapping("/updateSelect.do")
	public String update(wd_ht_customer bean){
		int i = service.updateByPrimaryKey(bean);
		System.out.println(i);
		return "redirect:toList.do";
	}
	@RequestMapping("/toDelete.do")
	public String delete(String customerId){
		System.out.println(customerId);
		int i = service.deleteByPrimaryKey(customerId);
		System.out.println(i);
		return "redirect:toList.do";
	}
}
